
public class Factory{

	interface XYZ
	{
		XYZ cloan();
	}
	
	static class Tom implements XYZ{
	public XYZ cloan()
	{
		return new Tom();
	}
	public String toString()
	{
		return "ttt";
	}
}
	static class Dick implements XYZ{
	public XYZ cloan()
	{
		return new Dick();
	}
	public String toString()
	{
		return "ddd";	
	}
	}
	
	static class Harry implements XYZ{
	public XYZ cloan()
	{
		return new Harry();
	}
	public String toString()
	{
		return "hhh";
	}
	}
	
	 static class Factory2{
		
		private static java.util.Map prototypes=new java.util.HashMap();
		static{
		prototypes.put("tom", new Tom());
		prototypes.put("dick", new Dick());
		prototypes.put("harry", new Harry());
		
	}
	public static XYZ makeObject(String s)
	{
		return ((XYZ)prototypes.get(s)).cloan();
	}
	public static void main(String args[])
	{
		for(int i=0;i<args.length;i++)
		{
			System.out.println(Factory2.makeObject(args[i])+" ");
		}	
	}
		
}
	

}

